Repository navigation
R23-T026: Input validation, boundary doctests, and 100% coverage for Newton's second law - #117
Open
mohammedsohail0301-dot wants to merge 1 commit into
Open
mohammedsohail0301-dot wants to merge 1 commit into
mohammedsohail0301-dot wants to merge 1 commit into
Conversation
…Newton's second law
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your change
Checklist
Description
This pull request completes Task R23-T026: bringing
physics/newtons_second_law_of_motion.pyup to repository standards by replacing exception-swallowing code with strict input validation guards and expanding doctests from 2 to 10 to achieve 100% test coverage.Problems Resolved:
newtons_second_law_of_motionusedtry ... except Exception: return -0.0, which silently masked invalid inputs, strings, or bugs by returning-0.0.Physical & Mathematical Decisions:
ValueError("Mass must be a non-negative value"). Non-numeric types and booleans raiseTypeError.TypeError.Type of Change
Input Decisions & Taxonomy Table
mass10,2.0mass0mass-5ValueErrormass"10",NoneTypeErrormassTrue)TrueTypeErrorboolas integer arithmetic.acceleration10,1acceleration0acceleration-9.8acceleration"10",NoneTypeErroraccelerationFalse)FalseTypeErrorChanges Made
physics/newtons_second_law_of_motion.py:try ... except Exception: return -0.0with explicit type guards and negative mass checks.Args:,Returns:, andRaises:(TypeError,ValueError).(10, 10) -> 100and(2.0, 1) -> 2.0).work/R23-T026/:FINDINGS.md: Complete theoretical justification, coverage progression, and test documentation.test_output.txt: Logs of doctest execution, pytest coverage, ruff lint, ruff format, and ty type check.Coverage & Verification
python3 -m doctest -v physics/newtons_second_law_of_motion.py-> 10/10 passed.uv run --with pytest-cov pytest physics/newtons_second_law_of_motion.py --doctest-modules --cov=physics --cov-report=term-missing-> 100% coverage.uvx ruff check physics/newtons_second_law_of_motion.py-> All checks passed.uvx ruff format --check physics/newtons_second_law_of_motion.py-> 1 file already formatted.uvx ty check --exit-zero physics/newtons_second_law_of_motion.py-> 0 diagnostics.Additional Notes
student/E26B07F0850/R23-T026-upstream(andR23-T026-upstream) containing only the changes inphysics/newtons_second_law_of_motion.pyhas been created and pushed for a later upstream PR.